package wangyachuan.sptingboot.exception;


import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import wangyachuan.sptingboot.common.Result;

/**
 * @author 王亚川
 */
@ControllerAdvice
public class GlobalException {
    @ExceptionHandler(ServiceException.class)//捕获ServiceException异常
    @ResponseBody//返回json数据
    public Result sericeException(ServiceException e) {
        return Result.error(e.getCode(),e.getMessage());
    }

}
